package br.com.financeiro.services;

import java.util.List;

import javax.transaction.Transactional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import br.com.financeiro.dao.GenericDao;

@Component
@Transactional
public class CrudService<T> {

	@Autowired
	private GenericDao dao;
	
	public void salvarOuAtualizar(T obj) {
		dao.salvarOuAtualizar(obj);
	}
	
	public void remover(T obj) {
		dao.remover(obj);
	}
	
	public T buscar(Class<T> classe, Integer id) {
		return dao.buscar(classe, id);
	}
	
	public List<T> findAll(Class<T> classe) {
		return dao.listar(classe, null);
	}

}
